import java.util.Arrays;

/**
 * @author wangj881
 * @date 2024-10-15 10:32
 */
public class L922 {
    public static void main(String[] args) {
//        int[] nums = {4, 2, 5, 7};
//        int[] nums = { 2, 5};
        int[] nums = {648, 831, 560, 986, 192, 424, 997, 829, 897, 843};
        int[] ints = new Solution().sortArrayByParityII(nums);
        System.out.println(Arrays.toString(ints));
    }

    static class Solution {
        public int[] sortArrayByParityII(int[] nums) {
            int[] result = new int[nums.length];
            int j = 1;
            int o = 0;
            for (int i = 0; i < nums.length; i++) {
                if (nums[i] % 2 == 0) {
                    result[o] = nums[i];
                    o += 2;
                } else {
                    result[j] = nums[i];
                    j += 2;
                }
            }
            return result;
        }
    }
}